/**   
 * Copyright © 2018 eSunny Info. Tech Ltd. All rights reserved.
 * 
 * @Package: com.eastcompeace.config 
 * @author: Zousonghua   
 * @date: 2018年4月16日 下午5:19:26 
 */
package com.eastcompeace.config;

import java.util.Arrays;

import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.eastcompeace.service.HelloService;
import com.eastcompeace.service.HelloServiceImpl;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;

/**
 * @ClassName: CXFConfig
 * @Description: TODO
 * @author: Zousonghua
 * @date: 2018年4月16日 下午5:19:26
 */
@Configuration
class CXFConfig {
	@Autowired
	private Bus bus;

	@Bean
	public Server rsServer() {
		final JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
		endpoint.setProvider(new JacksonJsonProvider());
		endpoint.setBus(bus);
		endpoint.setAddress("/");
		endpoint.setServiceBeans(Arrays.<Object>asList(userController()));
		endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
		return endpoint.create();
	}

	@Bean
	public HelloService userController() {
		return new HelloServiceImpl();
	}
}